package cn.hotel.service;

import cn.hotel.mapper.FrontEndMapper;
import cn.hotel.mapper.FrontEndMapperImpl;
import cn.hotel.pojo.ClientInformationManagement;
import cn.hotel.pojo.HouseType;
import cn.hotel.pojo.Member;
import cn.hotel.pojo.OrderManagement;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class FrontEndServiceImpl implements FrontEndService {
    private FrontEndMapper frontAndMapper = new FrontEndMapperImpl();

    //前端注册功能
    @Override
    public int register(ClientInformationManagement clientInformationManagement) {
        int registers = frontAndMapper.register(clientInformationManagement);
        return registers;
    }

    //同步到会员表表
    @Override
    public int synchronization(Member member) {
        int synchronizations = frontAndMapper.synchronization(member);
        return synchronizations;
    }

    //前端展示房型
    @Override
    public List<HouseType> show() {
        List<HouseType> houseType = frontAndMapper.show();
        return houseType;
    }

    //前端登录显示名字
    @Override
    public ClientInformationManagement checkName(String mobilePhone, String password) {
        ClientInformationManagement clientInformationManagement = frontAndMapper.checkName(mobilePhone);
        if (password != null && clientInformationManagement != null && password.equals(clientInformationManagement.getPassword())){
            return clientInformationManagement;
        }else {
            return null;
        }
    }

    //前端根据房型编号显示房型
    @Override
    public HouseType display(Long id) {
        HouseType houseTypeList = frontAndMapper.display(id);
        return houseTypeList;
    }

    //房型空房数
    @Override
    public int count(int houseTypeId) {
        int count = frontAndMapper.count(houseTypeId);
        return count;
    }

    //预定
    @Override
    public int reserve(OrderManagement orderManagement) {
        int reserves = frontAndMapper.reserve(orderManagement);
        return reserves;
    }
}
